package com.hwd.gmall.seckill.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hwd.gmall.model.activity.SeckillGoods;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 秒杀商品表单mapper映射
 *
 * @author 黄伟东/Victor
 * @date 2022/5/11 16:34
 */
@Mapper
public interface SeckillGoodsMapper extends BaseMapper<SeckillGoods> {

    /**
     * 同步秒杀商品的库存
     *
     * @param goodsId  商品id
     * @param stockNum 商品剩余的库存
     * @return int
     */
    @Update("UPDATE seckill_goods SET stock_count = #{stockNum} WHERE id = #{goodsId}")
    int updateStock(@Param("goodsId") Long goodsId, @Param("stockNum") Integer stockNum);
}
